package com.solver.mapper;

import com.github.pagehelper.Page;
import com.solver.annotation.AutoFill;
import com.solver.dto.QuestionPageQueryDTO;
import com.solver.entity.Question;
import com.solver.enumeration.OperationType;
import com.solver.vo.QuestionVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface QuestionMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from question where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @AutoFill(value = OperationType.INSERT)
    void insert(Question question);

    Page<QuestionVO> questionPageQuery(QuestionPageQueryDTO questionPageQueryDTO);

    @Select("select * from question where id = #{id}")
    Question getById(Long id);

//    @Delete("delete  from question where id = #{id}")
//    void delete(Long id);

    void deleteByIds(List<Long> ids);

    @AutoFill(value = OperationType.UPDATE)
    void update(Question question);

    List<Question> list(Question question);
}
